if config_h.has('HAVE_WAYLAND') == true
  subdir('generated')
endif

e_fm_shared_types = configuration_data()
e_fm_shared_types.set10('EEZE_MOUNT_CONFIG', config_h.has('HAVE_EEZE_MOUNT'))
e_fm_shared_types.set10('DBUS_MOUNT_CONFIG', config_h.has('HAVE_UDISKS_MOUNT'))

configure_file(input        : 'e_fm_shared_types.h.in',
               output       : 'e_fm_shared_types.h',
               configuration: e_fm_shared_types,
               install_dir  : dir_include_e)

deps_e = [
  dep_rt,
  dep_m,
  dep_dl,
  dep_execinfo,
  dep_eina,
  dep_eet,
  dep_eeze,
  dep_ecore,
  dep_ecore_ipc,
  dep_ecore_file,
  dep_ecore_con,
  dep_ecore_input,
  dep_ecore_input_evas,
  dep_ecore_audio,
  dep_evas,
  dep_efreet,
  dep_efreet_mime,
  dep_eio,
  dep_eldbus,
  dep_emotion,
  dep_elementary,
  dep_elput,
  dep_intl
]

if config_h.has('HAVE_LIBEXIF') == true
  deps_e += dep_libexif
endif

deps_ckpass = [ dep_eina, dep_ecore, dep_eldbus ]

if freebsd == true
  deps_ckpass += dep_crypt
endif

if config_h.has('HAVE_PAM') == true
  deps_ckpass += dep_pam
endif

requires_e = ' '.join([
  ' '.join(['eina', efl_version]),
  'eet',
  'ecore',
  'ecore-ipc',
  'ecore-file',
  'ecore-con',
  'ecore-input',
  'ecore-input-evas',
  'ecore-audio',
  'evas',
  'efreet',
  'efreet-mime',
  'eio',
  requires_eeze,
  'eldbus',
  'emotion',
  'elementary'
])

src = [
  'e_about.c',
  'e_acpi.c',
  'e_actions.c',
  'e_atoms.c',
  'e_auth.c',
  'e_backlight.c',
  'e_bg.c',
  'e_bindings.c',
  'e_client.c',
  'e_client_volume.c',
  'e_color.c',
  'e_color_dialog.c',
  'e_comp.c',
  'e_comp_canvas.c',
  'e_comp_cfdata.c',
  'e_comp_object.c',
  'e_config.c',
  'e_config_data.c',
  'e_config_dialog.c',
  'e_configure.c',
  'e_confirm_dialog.c',
  'e_datastore.c',
  'e_dbusmenu.c',
  'e_desk.c',
  'e_deskenv.c',
  'e_desklock.c',
  'e_deskmirror.c',
  'e_dialog.c',
  'e_dpms.c',
  'e_desktop_editor.c',
  'e_dnd.c',
  'e_entry_dialog.c',
  'e_env.c',
  'e_error.c',
  'e_exec.c',
  'e_exehist.c',
  'e_filereg.c',
  'e_flowlayout.c',
  'e_fm.c',
  'e_fm_custom.c',
  'e_fm_device.c',
  'e_fm_mime.c',
  'e_fm_op_registry.c',
  'e_fm_prop.c',
  'e_fm_shared_codec.c',
  'e_fm_shared_device.c',
  'e_focus.c',
  'e_font.c',
  'e_gadcon.c',
  'e_gadcon_popup.c',
  'e_grabinput.c',
  'e_grab_dialog.c',
  'e_hints.c',
  'e_icon.c',
  'e_ilist.c',
  'e_import_config_dialog.c',
  'e_import_dialog.c',
  'e_init.c',
  'e_int_client_locks.c',
  'e_int_client_menu.c',
  'e_int_client_prop.c',
  'e_int_client_remember.c',
  'e_int_config_modules.c',
  'e_int_config_comp.c',
  'e_int_config_comp_match.c',
  'e_int_gadcon_config.c',
  'e_intl.c',
  'e_intl_data.c',
  'e_int_menus.c',
  'e_int_shelf_config.c',
  'e_int_toolbar_config.c',
  'e_ipc.c',
  'e_ipc_codec.c',
  'e_layout.c',
  'e_livethumb.c',
  'e_log.c',
  'e_main.c',
  'e_maximize.c',
  'e_menu.c',
  'e_module.c',
  'e_mouse.c',
  'e_moveresize.c',
  'e_msgbus.c',
  'e_notification.c',
  'e_msg.c',
  'e_obj_dialog.c',
  'e_object.c',
  'e_order.c',
  'e_pan.c',
  'e_path.c',
  'e_pixmap.c',
  'e_place.c',
  'e_pointer.c',
  'e_powersave.c',
  'e_prefix.c',
  'e_randr2.c',
  'e_remember.c',
  'e_resist.c',
  'e_scale.c',
  'e_screensaver.c',
  'e_scrollframe.c',
  'e_sha1.c',
  'e_shelf.c',
  'e_signals.c',
  'e_slidecore.c',
  'e_slider.c',
  'e_slidesel.c',
  'e_spectrum.c',
  'e_startup.c',
  'e_state.c',
  'e_sys.c',
  'e_system.c',
  'e_test.c',
  'e_theme_about.c',
  'e_theme.c',
  'e_thumb.c',
  'e_toolbar.c',
  'e_update.c',
  'e_user.c',
  'e_utils.c',
  'e_video.c',
  'e_watchdog.c',
  'e_widget_aspect.c',
  'e_widget_button.c',
  'e_widget.c',
  'e_widget_check.c',
  'e_widget_color_well.c',
  'e_widget_config_list.c',
  'e_widget_bgpreview.c',
  'e_widget_entry.c',
  'e_widget_filepreview.c',
  'e_widget_flist.c',
  'e_widget_font_preview.c',
  'e_widget_framelist.c',
  'e_widget_frametable.c',
  'e_widget_fsel.c',
  'e_widget_ilist.c',
  'e_widget_image.c',
  'e_widget_label.c',
  'e_widget_list.c',
  'e_widget_preview.c',
  'e_widget_radio.c',
  'e_widget_scrollframe.c',
  'e_widget_slider.c',
  'e_widget_spectrum.c',
  'e_widget_table.c',
  'e_widget_textblock.c',
  'e_widget_toolbar.c',
  'e_widget_toolbook.c',
  'e_win.c',
  'e_xkb.c',
  'e_xinerama.c',
  'e_zoomap.c',
  'e_zone.c',
  'e_gesture.c',
  'e_sound.c',
  'efx/efx_bumpmapping.c',
  'efx/efx.c',
  'efx/efx_fade.c',
  'efx/efx_helpers.c',
  'efx/efx_move.c',
  'efx/efx_pan.c',
  'efx/e_efx_private.h',
  'efx/efx_queue.c',
  'efx/efx_resize.c',
  'efx/efx_rotate.c',
  'efx/efx_spin.c',
  'efx/efx_util.c',
  'efx/efx_zoom.c',
  'valgrind.h'
]

hdr = [
  'efx/e_Efx.h',
  'e_about.h',
  'e_acpi.h',
  'e_actions.h',
  'e_alert.h',
  'e_atoms.h',
  'e_auth.h',
  'e_backlight.h',
  'e_bg.h',
  'e_bindings.h',
  'e_client.h',
  'e_client_volume.h',
  'e_client.x',
  'e_color_dialog.h',
  'e_color.h',
  'e_comp.h',
  'e_comp_canvas.h',
  'e_comp_cfdata.h',
  'e_comp_object.h',
  'e_comp_x.h',
  'e_comp_x_devices.h',
  'e_comp_x_randr.h',
  'e_config_data.h',
  'e_config_dialog.h',
  'e_config.h',
  'e_configure.h',
  'e_confirm_dialog.h',
  'e_datastore.h',
  'e_dbusmenu.h',
  'e_desk.h',
  'e_deskenv.h',
  'e_desklock.h',
  'e_deskmirror.h',
  'e_dialog.h',
  'e_dnd.h',
  'e_dpms.h',
  'e_desktop_editor.h',
  'e_entry_dialog.h',
  'e_env.h',
  'e_error.h',
  'e_exec.h',
  'e_exehist.h',
  'e_filereg.h',
  'e_flowlayout.h',
  'e_fm_custom.h',
  'e_fm_device.h',
  'e_fm.h',
  'e_fm_mime.h',
  'e_fm_op.h',
  'e_fm_op_registry.h',
  'e_fm_prop.h',
  'e_fm_shared_codec.h',
  'e_fm_shared_device.h',
  'e_focus.h',
  'e_font.h',
  'e_gadcon.h',
  'e_gadcon_popup.h',
  'e_grabinput.h',
  'e_grab_dialog.h',
  'e.h',
  'e_macros.h',
  'e_hints.h',
  'e_icon.h',
  'e_ilist.h',
  'e_import_config_dialog.h',
  'e_import_dialog.h',
  'e_includes.h',
  'e_init.h',
  'e_int_client_locks.h',
  'e_int_client_menu.h',
  'e_int_client_prop.h',
  'e_int_client_remember.h',
  'e_int_config_modules.h',
  'e_int_gadcon_config.h',
  'e_intl_data.h',
  'e_intl.h',
  'e_int_menus.h',
  'e_int_shelf_config.h',
  'e_int_toolbar_config.h',
  'e_ipc_codec.h',
  'e_ipc.h',
  'e_layout.h',
  'e_livethumb.h',
  'e_log.h',
  'e_maximize.h',
  'e_menu.h',
  'e_mmx.h',
  'e_module.h',
  'e_mouse.h',
  'e_moveresize.h',
  'e_msgbus.h',
  'e_notification.h',
  'e_msg.h',
  'e_obj_dialog.h',
  'e_object.h',
  'e_order.h',
  'e_pan.h',
  'e_path.h',
  'e_pixmap.h',
  'e_place.h',
  'e_pointer.h',
  'e_powersave.h',
  'e_prefix.h',
  'e_randr2.h',
  'e_remember.h',
  'e_resist.h',
  'e_scale.h',
  'e_screensaver.h',
  'e_scrollframe.h',
  'e_sha1.h',
  'e_shelf.h',
  'e_signals.h',
  'e_slidecore.h',
  'e_slider.h',
  'e_slidesel.h',
  'e_spectrum.h',
  'e_startup.h',
  'e_state.h',
  'e_sys.h',
  'e_system.h',
  'e_test.h',
  'e_theme_about.h',
  'e_theme.h',
  'e_thumb.h',
  'e_toolbar.h',
  'e_update.h',
  'e_user.h',
  'e_utils.h',
  'e_video.h',
  'e_watchdog.h',
  'e_widget_aspect.h',
  'e_widget_button.h',
  'e_widget_check.h',
  'e_widget_color_well.h',
  'e_widget_config_list.h',
  'e_widget_bgpreview.h',
  'e_widget_entry.h',
  'e_widget_filepreview.h',
  'e_widget_flist.h',
  'e_widget_font_preview.h',
  'e_widget_framelist.h',
  'e_widget_frametable.h',
  'e_widget_fsel.h',
  'e_widget.h',
  'e_widget_ilist.h',
  'e_widget_image.h',
  'e_widget_label.h',
  'e_widget_list.h',
  'e_widget_preview.h',
  'e_widget_radio.h',
  'e_widget_scrollframe.h',
  'e_widget_slider.h',
  'e_widget_spectrum.h',
  'e_widget_table.h',
  'e_widget_textblock.h',
  'e_widget_toolbar.h',
  'e_widget_toolbook.h',
  'e_win.h',
  'e_xinerama.h',
  'e_xkb.h',
  'e_xsettings.h',
  'e_zoomap.h',
  'e_zone.h',
  'e_gesture.h',
  'e_sound.h'
]

if config_h.has('HAVE_WAYLAND') == true
  src += [
    'e_comp_wl_data.c',
    'e_comp_wl_input.c',
    'e_comp_wl_dmabuf.c',
    'e_comp_wl.c',
    'e_comp_wl_extensions.c',
    'e_comp_wl_extensions_tizen.c',
    wayland_proto_c,
    wayland_proto_h
  ]
  hdr += [
    'e_comp_wl_data.h',
    'e_comp_wl_dmabuf.h',
    'e_comp_wl_input.h',
    'e_comp_wl.h'
  ]
  deps_e += dep_wayland
  requires_e = ' '.join([requires_e, requires_wayland])
endif

if config_h.has('HAVE_WAYLAND_ONLY') == false
  src += [
    'e_comp_x.c',
    'e_comp_x_devices.c',
    'e_comp_x_randr.c',
    'e_alert.c',
    'e_xsettings.c'
  ]
  deps_e += dep_ecore_x
  requires_e = ' '.join([requires_e, 'ecore-x'])
endif

install_headers( hdr, subdir: 'enlightenment' )

executable('enlightenment', src,
           include_directories: include_directories('.', 'efx', 'generated', '../..'),
           dependencies       : deps_e,
           c_args             : '-DE_LOGGING=1',
           link_args          : '-rdynamic',
           install_dir        : dir_bin,
           install            : true
          )

dir_e_utils = join_paths(dir_lib, 'enlightenment/utils')

executable('enlightenment_imc',
           [ 'e_config_data.c',
             'e_imc_main.c',
             'e_intl_data.c'
           ],
           include_directories: include_directories('.', '../..'),
           dependencies       : [ dep_eina, dep_eet, dep_ecore_file ],
           install_dir        : dir_bin,
           install            : true
          )

executable('enlightenment_start',
           [ 'e_start_main.c' ],
           include_directories: include_directories('../..'),
           dependencies       : dep_eina,
           install_dir        : dir_bin,
           install            : true
          )

executable('enlightenment_fm_op',
           [ 'e_fm_op.c' ],
           include_directories: include_directories('../..'),
           dependencies       : [ dep_m, dep_eina, dep_ecore, dep_ecore_file ],
           install_dir        : dir_e_utils,
           install            : true
          )

executable('enlightenment_thumb',
           [ 'e_thumb_main.c', 'e_sha1.c', 'e_user.c' ],
           include_directories: include_directories('../..'),
           dependencies       : [ dep_m, dep_eina, dep_eet, dep_evas, dep_ecore, dep_ecore_ipc, dep_ecore_evas, dep_efreet, dep_ecore_file, dep_edje, dep_emotion ],
           install_dir        : dir_e_utils,
           install            : true
          )

executable('enlightenment_elm_cfgtool',
           [ 'e_elm_cfgtool_main.c' ],
           include_directories: include_directories('../..'),
           dependencies       : [ dep_m, dep_elementary ],
           install_dir        : dir_e_utils,
           install            : true
          )

executable('enlightenment_wallpaper_gen',
           [ 'e_wallpaper_gen_main.c' ],
           include_directories: include_directories('../..'),
           dependencies       : [ dep_elementary ],
           install_dir        : dir_e_utils,
           install            : true
          )

deps_e_alert = [ dep_elementary ]
if config_h.has('HAVE_WAYLAND_ONLY') == false
  deps_e_alert += [
    dep_ecore_x
  ]
endif
executable('enlightenment_alert',
           [ 'e_alert_main.c' ],
           include_directories: include_directories('../..'),
           dependencies       : [ deps_e_alert ],
           install_dir        : dir_e_utils,
           install            : true
          )

executable('enlightenment_sys',
           [ 'e_sys_main.c' ],
           include_directories: include_directories('../..'),
           dependencies       : [dep_eina, dep_ecore, dep_bluez],
           c_args             : suid_cflags,
           link_args          : suid_ldflags,
           install_dir        : dir_e_utils,
           install            : true
          )
suid_exes += join_paths(dir_e_utils, 'enlightenment_sys')

executable('enlightenment_ckpasswd',
           'e_ckpasswd_main.c',
           include_directories: include_directories('../..'),
           dependencies : deps_ckpass,
           c_args       : suid_cflags,
           link_args    : suid_ldflags,
           install_dir  : dir_e_utils,
           install      : true
          )
suid_exes += join_paths(dir_e_utils, 'enlightenment_ckpasswd')

subdir('e_fm')
subdir('system')
subdir('tools')
